<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ include file="../include/taglib.jsp"%>
<%
	String pageModule= request.getParameter("page");
%>
<html>
  <head>
    <title>My JSP 'showjspmodule.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<%@ include file="../include/common.jsp"%>
  	<%@ include file="../include/tree.jsp"%>
  	<script type="text/javascript">
  	var pageId = '<%=pageModule%>';
  	$(document).ready(function() {
  		
	 	var setting = {
	 		check: {
				enable: true,
				chkboxType:{ "Y" : "ps", "N" : "ps" }
			},
			async : {
				enable : true,
				url : "../../portlet/portal!pageModuleTree.action",
				dataType : "text"
			},
			view : {
				showLine : true,
				expandSpeed : ""
			},
			callback : {
				onClick : function(event, treeId, treeNode) {
					nodeId = treeNode.id;
				}
			}
		};
	  	$.fn.zTree.init($("#moduleTree"), setting);
  	});
  	function submitIt(){
  		var treeObj = $.fn.zTree.getZTreeObj("moduleTree");
  		var nodes = treeObj.getCheckedNodes(true);
  		var ids="";
  		for(var i=0; i<nodes.length; i++){
  			var n = nodes[i];
  			if(n.isParent){
  				continue;
  			}
  			if(ids==''){
  				ids=n.id;
  			}else{
  				ids+="#"+n.id;
  			}
  		}
		$.ajax({
			url : "../../portlet/portal!savePageConf.action",
			cache : false,
			global : false,
			async : false,
			data:{'pageId':pageId,"moduleIds":ids},
			success : function(items) {
				reloadPage();
				closewin();
			}
		});
  		
  	}
  	function reloadPage()
  	{
  		var win = getTopWin(window).currentWin["show-jsp-module"];
  		win.reloadPage();
  	}
  function closewin(){
	   getTopWin(window).closejBox("show-jsp-module");
  }
  	
  	</script>
  </head>
  <body>
	<ul id='moduleTree' class='ztree' style='margin:0px; padding:0px; height: 410px; '></ul>
	<div  class="btn-div" >
		<button type="button" id ="saveBt" value="保存" class="btn-4" onclick="submitIt();">提交</button>
    	<button type="button" onclick="closewin();" class="btn-4" >关闭</button>
    	</div>
  </body>
</html>
